import pymysql

# 连接db
conn = pymysql.connect(
    host='127.0.0.1',
    user='root',
    password='123456',
    database='duanhh',
    charset='utf8'
)

# 得到可以执行SQL的cursor对象

cursor = conn.cursor()

# 定义SQL语句
sql = 'select * from myuser'
cursor.execute(sql)
result = cursor.fetchall()
print(result)
conn.close()